package com.tuyrt.hi.ui.app.demo.refresh

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import com.airbnb.lottie.LottieAnimationView
import com.tuyrt.hi.ui.app.R
import com.tuyrt.hi.ui.refresh.HiOverView


/**
 * author: Administrator on 2021/4/30.
 * desc: Lottie loading View
 */
class HiLottieOverView constructor(context: Context, attrs: AttributeSet? = null, def: Int = 0) :
    HiOverView(context, attrs, def) {

    private lateinit var pullAnimationView: LottieAnimationView

    override fun init() {
        LayoutInflater.from(context).inflate(R.layout.lottie_overview, this, true)
        pullAnimationView = findViewById(R.id.pull_animation)
        pullAnimationView.setAnimation("loading_wave.json")
    }

    override fun onScroll(scrollY: Int, pullRefreshHeight: Int) {}
    override fun onVisible() {

    }

    override fun onOver() {

    }

    override fun onRefresh() {
        pullAnimationView.speed = 2f
        pullAnimationView.playAnimation()

    }

    override fun onFinished() {
        pullAnimationView.progress = 0f
        pullAnimationView.cancelAnimation()
    }
}